package com.yugao.fintech.libra.shortlink.model.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yugao.fintech.libra.common.BasePlusPO;
import com.yugao.fintech.libra.common.tenant.core.DataIsolation;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * 短链
 */
@Getter
@Setter
@TableName("sl_short_link")
@DataIsolation(filterTenant = true, tableName = "sl_short_link")
public class ShortLink extends BasePlusPO {
    @TableId
    private Long id;

    /**
     * 组
     */
    private Long groupId;

    /**
     * 短链标题
     */
    private String title;

    /**
     * 原始url
     */
    private String originalUrl;

    /**
     * 短链域名
     */
    private String domain;

    /**
     * 短链域名
     */
    private Long domainId;

    /**
     * 短链压缩码
     */
    private String code;

    /**
     * 长链的md5码, 方便查找
     */
    private String sign;

    /**
     * 租户id
     */
    private Long tenantId;

    /**
     * 过期时间, 为空就是长久
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Date expireTime;

    /**
     * 关联的用户id
     */
    private Long userId;

    /**
     * 0是没有, 1是删除
     */
    private Integer deleted;

    /**
     * 状态, lock(2)是锁定不可用, active(1)是可用
     */
    private String status;

    public interface Status {
        String LOCK = "0";
        String ACTION = "1";
        /**
         * 过期
         */
        String EXPIRED = "2";
    }

    public static LambdaQueryWrapper<ShortLink> lqw() {
        return Wrappers.lambdaQuery();
    }

    public static LambdaUpdateWrapper<ShortLink> luw() {
        return Wrappers.lambdaUpdate();
    }
}
